package com.reservation.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 订单状态枚举
 */
@Getter
@AllArgsConstructor
public enum BookingStatus {

    CONFIRMED(0, "预约成功已确认"),
    PENDING_PAYMENT(1, "待支付"),
    CANCELLED_REQUESTED(2, "取消申请中"),
    CANCELLED_NEED_CONFIRM(3, "取消待确认"),
    CANCELLED_FAILED(4, "取消申请被拒绝"),
    CANCELLED_REFUNDED(5, "已取消并退款"),
    EXPIRED(6, "已过期"),
    COMPLETED(7, "已完成");

    private final Integer code;
    private final String desc;

    /**
     * 根据状态码获取枚举
     */
    public static BookingStatus getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        
        for (BookingStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
}